package com.xindz.cn.mvptest.login;

import com.xindz.cn.mvptest.base.BasePresenter;
import com.xindz.cn.mvptest.utils.HttpUtils;

/**
 * @name MvpTest
 * @class name：com.xindz.cn.mvptest.login
 * @describe describe
 * @anthor XINDZ
 * @time 2017/10/27 9:34
 * @change
 * @chang time
 * @class describe
 */
public class LoginPresenter extends BasePresenter<LoginView> {
    //持有M层引用
    private LoginModel loginModel;

    //构造方法绑定UI层
    public LoginPresenter() {
        this.loginModel = new LoginModel();
    }

    public void login(String username, String password) {
        this.loginModel.login(username, password, new HttpUtils.OnHttpResultListener() {
            @Override
            public void onResult(String result) {
                //回调UI层->和UI进行交互
                if (getView() != null) {
                    getView().onLoginResult(result);
                }
            }
        });
    }
}
